<!-- 新增用户 -->
<template>
    <div class="">
        <dy-form 
            :elForm_Options="elForm_Options"
            @bottonHandle="opbuttonclick"
            :flagIndex="flagIndex"
            ref="myForm"
        />
    </div>
</template>

<script setup>
import { ref, shallowRef, onMounted } from 'vue'
import { Upload, Plus } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

const router = useRouter()

let elForm_Options = ref({
    pagetitle: '用户',
    getwayname: 'users',
    wt_mesage: [{
        prop: 'username',
        label: '用户名',
        paramtype: 'input',
        allwidth: true,
        required: true
    },{
        prop: 'real_name',
        label: '真实姓名',
        paramtype: 'input',
        required: true
    },{
        prop: 'user_id',
        label: '工号',
        paramtype: 'input',
        required: true
    },{
        label: '头像',
        prop: 'avatar',
        paramtype: 'avatarupload',
        allwidth: true
    },{
        prop: 'email',
        label: '邮箱',
        paramtype: 'input'
    },{
        prop: 'role_ids',
        label: '选择角色',
        paramtype: 'chooserole'
    }],
    opbutton: [{
        label: '保存',
        dealway: 'submitForm',
        icon: shallowRef(Plus),
        type: "primary",
        keyV: "add",
        flagIndexList:  ['edit', 'create'],
        disabled: false
    }],
})

let flagIndex = ref('create')

//实例
let myForm = ref(null)

let opbuttonclick = (wayname) => {
    if(wayname == 'returnPage'){
        //返回
        router.push('/systemManage/userManagement')
    }else if(wayname == 'submitForm'){
        myForm.value.submitFormData()
    }
}

</script>

<style lang="scss" scoped>
    
</style>